package org.news.web;

import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import org.apache.log4j.Logger;
import org.news.entity.User;

public class OnlineUser implements HttpSessionBindingListener {
    private Student student;

    @Override
    public void valueBound(HttpSessionBindingEvent arg0) {
        ServletContext application = arg0.getSession().getServletContext();
        @SuppressWarnings("unchecked")
        List<Student> onlineUserList = (List<Student>) application
                .getAttribute("student");
        onlineUserList.add(student);
        student.setName(student.getName()+10);
        
    }

   

	@Override
    public void valueUnbound(HttpSessionBindingEvent arg0) {
        ServletContext application = arg0.getSession().getServletContext();
        @SuppressWarnings("unchecked")
        List<Student> onlineUserList = (List<Student>) application
                .getAttribute("student");
        onlineUserList.remove(student);
        student.setName(student.getName()-10);
        
    }

    
}
